import { IFeidaoAiNodejsComponent } from '@dfeidao/atom-nodejs/interfaces';
import nodejs from '@dfeidao/atom-nodejs/msg/nodejs';
import render from '@dfeidao/atom-nodejs/render/render';
import p001 from './p001';
import get from '@dfeidao/atom-web/global/get';
import p002 from './p002';
import p003 from './p003';
import p004 from './p004';

export default async function na001(fd: IFeidaoAiNodejsComponent) {
	// todo
	const res = await nodejs<{d1:Array<{department_no:string,deptname:string}>;d2:Array<{project_no:string,project_name:string}>;d3:Array<{source_type:string,work_order_status:string}>}>(fd.data.actionid,fd.data.sessionid,'test-web/zj-000002/s001');
	render(fd.data.node,res.d1,p001,'p001');
	render(fd.data.node,"",p002,'p002');
	const ret = Array();
	for (let i = 0; i < res.d3.length; i++) {
		ret[i] = res.d3[i].source_type;
	}
	const ret1 = Array();
	for (let i = 0; i < res.d3.length; i++) {
		ret1[i] = res.d3[i].work_order_status;
	}
	const d = Array.from(new Set(ret1));
	const h = Array();
	for (let i = 0; i < d.length; i++) {
		if(d[i]=="1"){
			h[i]="结单";
		}else if(d[i]=="2"){
			h[i]="完成";
	
		}else if(d[i]=="3"){
			h[i]="挂起";
	
		}else if(d[i]=="4"){
			h[i]="未派单";
	
		}else{
			h[i]="进行中";
		}
	}
	//1:结单2:完成3:挂起4:未派单5:进行中
	const v = Array();
	for (let index = 0; index <d.length; index++) {
		v[index] = {s:d[index],a:h[index]};
	}
	const s = Array.from(new Set(ret));
	const a = Array();
	for (let i = 0; i < s.length; i++) {
		if(s[i]=="1"){
			a[i]="总服务台";
		}else if(s[i]=="2"){
			a[i]="服务台";
	
		}else if(s[i]=="3"){
			a[i]="客户报障";
	
		}else{
			a[i]="内部报障";
		}
	}
	const b = Array();
	for (let index = 0; index <s.length; index++) {
		b[index] = {s:s[index],a:a[index]};
	}


	const department_no=get("department_no");
	
}
